const express = require('express');
const warningController = require('../controllers/warningController');
const authController = require('../controllers/authController');

const router = express.Router();

// 公共路由 - 不需要认证
router.get('/current', warningController.getCurrentWarnings);

// 保护以下所有路由，需要登录
router.use(authController.protect);

// 发送测试邮件
router.get('/test-email', warningController.sendTestEmail);

// 获取用户的所有预警
router.get('/', warningController.getUserWarnings);

// 创建新预警
router.post('/', warningController.createWarning);

// 获取/更新/删除单个预警
router.route('/:id')
  .get(warningController.getWarning)
  .patch(warningController.updateWarning)
  .delete(warningController.deleteWarning);

module.exports = router; 